#pragma once

#include <sys/epoll.h>
#include <vector>

class Epoller {
private:
    int epoll_fd;  // epoll实例
    std::vector<struct epoll_event> epoll_events;

public:
    explicit Epoller(unsigned max_events);
    ~Epoller();

    // 对事件数组操作封装
    bool add_event(int fd, uint32_t events) const;
    bool modify_event(int fd, uint32_t events) const;
    bool delete_event(int fd) const;

    int epoller_wait(int timeout = -1);
    int get_event_fd(size_t index) const;
    uint32_t get_events(size_t i) const;
};